package org.example.cardgame.service;

import org.example.cardgame.entity.Card;

import java.util.*;

/**
 * @Author juanita.ren
 * @Date 2024/11/11 22:56
 * @Version 1.0
 */

public class CardGroups {
    private Queue<Card> cardQueue = new LinkedList();

    public CardGroups() {
    }

    public void refreshGroup() {
        List<Card> cardList = new ArrayList();

        for(int i = 1; i <= 13; ++i) {
            cardList.add(new Card(1, i));
            cardList.add(new Card(0, i));
            cardList.add(new Card(3, i));
            cardList.add(new Card(2, i));
        }

        Collections.shuffle(cardList);
        this.cardQueue.clear();
        this.cardQueue.addAll(cardList);
    }

    public List<Card> drawCard(int count) {
        List<Card> cardList = new ArrayList();

        for(int i = 0; i < count; ++i) {
            Card card = (Card)this.cardQueue.poll();
            cardList.add(card);
        }

        return cardList;
    }
}